package PatientTests;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class PatientTest {
	private static medical_application.Patient patient1;
	private medical_application.Patient patient2;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		patient1 = new medical_application.Patient();
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
		patient1 = null;
	}

	@Before
	public void setUp() throws Exception {
		String first = "TestFirst";
		String middle = "TestMiddle";
		String last = "TestLast";
		String address = "Address, Street, City";
		String insurance = "AllState";
		String allergies = "Nuts, Bees";
		String scripts = "None Test";
		String dob = "MONTH/DAY/YEAR";
		String age = "17";
		String phone = "715-317-6874";
		patient2 = new medical_application.Patient( first, middle, last, address, insurance, allergies, scripts, dob, age, phone );
	}

	@After
	public void tearDown() throws Exception {
		patient2 = null;
	}

	@Test
	public final void testPatient() {
		assertEquals( "", patient1.getFirst() );
		assertEquals( "", patient1.getMiddle() );
		assertEquals( "", patient1.getLast() );
		assertEquals( "", patient1.getAddress() );
		assertEquals( "", patient1.getDOB() );
		assertEquals( "", patient1.getPhone() );
		assertEquals( "", patient1.getInsurance() );
		assertEquals( "", patient1.getAllergies() );
		assertEquals( "", patient1.getScripts() );
		assertEquals( "", patient1.getAge() );
	}

	@Test
	public final void testPatientStringStringStringStringStringStringStringStringStringString() {
		assertEquals( "TestFirst", patient2.getFirst() );
		assertEquals( "TestMiddle", patient2.getMiddle() );
		assertEquals( "TestLast", patient2.getLast() );
		assertEquals( "Address, Street, City", patient2.getAddress() );
		assertEquals( "MONTH/DAY/YEAR", patient2.getDOB() );
		assertEquals( "715-317-6874", patient2.getPhone() );
		assertEquals( "AllState", patient2.getInsurance() );
		assertEquals( "Nuts, Bees", patient2.getAllergies() );
		assertEquals( "None Test", patient2.getScripts() );
		assertEquals( "17", patient2.getAge() );
		
		/* Now reconstruct the patient object and assert changes were made */
		String first = "TEST CHANGE FIRST";
		String middle = "TestMiddle";
		String last = "TestLast";
		String address = "Address, Street, City";
		String insurance = "AllState";
		String allergies = "Nuts, Bees";
		String scripts = "None Test";
		String dob = "MONTH/DAY/YEAR";
		String age = "17";
		String phone = "715-317-6874";
		patient2 = new medical_application.Patient( first, middle, last, address, insurance, allergies, scripts, dob, age, phone );
		
		/* Reassert the first name to see change in object via constructor */
		
		assertEquals( "TEST CHANGE FIRST", patient2.getFirst() );
	}

	@Test
	public final void testToString() {
		/* Grab the patient2 object and check that it's toString works */
		/* Format: Last Name, First Name, DoB */
		
		String toStr = patient2.toString();
		String testToStr = "TestLast, TestFirst, MONTH/DAY/YEAR";
		
		assertEquals( testToStr, toStr );
	}

}
